import request from '@/utils/request'

export function login(username, password) {
  return request({
    url: '/auth/login',
    method: 'post',
    data: {
      username,
      password
    },
    transformRequest: [function (data) {
      let ret = ''
      for (let it in data) {
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
      }
      return ret
    }]
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info/authentication',
    method: 'get',
    params: {}
  })
}

export function logout() {
  return request({
    url: '/auth/logout',
    method: 'post'
  })
}
